Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new module TroykaMeteoSensor #71

Merged
merged 2 commits into from
Aug 27, 2018
Merged

new module TroykaMeteoSensor #71

merged 2 commits into from
Aug 27, 2018

Conversation

PSVM-J
Copy link
Contributor

@PSVM-J PSVM-J commented Aug 23, 2018

Copy link
Contributor

@igrztv igrztv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил пунктуацию и кодстайл в документации

@@ -0,0 +1,113 @@
function TroykaMeteoSensor(opts) {
opts = opts || {};
var _i2c = opts.i2c || PrimaryI2C;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в документации сказано, что объект opts ''должен'' содержать поля.
по факту он ''может'' содержать, но не обязан

};

this.clockStretchingOn = function() {
_clockStretching = "ON"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если Iskra JS не умеет пользоваться clockStretching, то лучше не давать ручку к нему.

var data = _i2c.readFrom(_address, 6);
if (data[2] != _checkCRC8(data, 0, 2) || data[5] != _checkCRC8(data, 3, 5)) {
callback(new Error('checksum error'), {
tempC: -1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не знаю как правильно, но я бы сделал undefined в случае ошибки. Так было бы проще отловить, что «что-то не то» в данных температуры. Иначе возникает вопрос «да почему минус один-то?», если человек не обрабатывает ошибки

@PSVM-J
Copy link
Contributor Author

PSVM-J commented Aug 27, 2018

Убрал выбор clockStretching, возвращаю undefined в случае ошибки, завернул все вызовы i2c в try...catch и возвращаю ошибку...

@PSVM-J PSVM-J closed this Aug 27, 2018
@PSVM-J PSVM-J reopened this Aug 27, 2018
@igrztv
Copy link
Contributor

igrztv commented Aug 27, 2018

LGTM

@igrztv igrztv closed this Aug 27, 2018
@igrztv igrztv reopened this Aug 27, 2018
@nomad605dis
Copy link
Collaborator

LGTM

@PSVM-J PSVM-J merged commit e6bb6a5 into master Aug 27, 2018
@PSVM-J PSVM-J deleted the meteo-sensor branch August 27, 2018 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants